﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data;
using System.IO;
using System.Web;
using Newtonsoft.Json;

namespace SnippetBox.Core.Infrastructure {
    public sealed class Settings : SettingsBase {
        static Settings() {} 

        static readonly Settings _instance = new Settings();
        public static Settings Current { get { return _instance; } }
        
        public GeneralSettings General { get; set; }
        public PermissionSettings Permissions { get; set; }
        public AdvancedSettings Advanced { get; set; }

        public override void SetDefaultValues() {
            General = new GeneralSettings();
            General.SiteTitle = "SnippetBox";
            General.Theme = "green";

            Permissions = new PermissionSettings();
            Permissions.AllowRegistration = true;
            Permissions.AllowMembersToCreateSnippets = true;

            Advanced = new AdvancedSettings();
        }
    }

    public class GeneralSettings {
        [Display(Name = "Site title",
                Description = "Site title of your Snippet Box")]
        public string SiteTitle { get; set; }
        
        [UIHint("ThemePicker")]
        [Display(Description = "Set look and feel of the site.")]
        public string Theme { get; set; }
    }

    public class PermissionSettings {
        [Display(Name = "Members can create snippets", 
                 Description = "Enable to let users of role Member create snippets.")]
        public bool AllowMembersToCreateSnippets { get; set; }

        [Display(Name = "Require login",
                 Description = "Require anonymous users to login to see snippets.")]
        public bool RequireLogin { get; set; }

        [Display(Name = "Allow registration",
                 Description = "Let visitors register on the site.")]
        public bool AllowRegistration { get; set; }
    }

    public class AdvancedSettings {
        [Display(Name = "Debug mode",
         Description = "Show debug and performance information.")]
        public bool DebugMode { get; set; }
    }
}
